<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>Blank Page - Ace Admin</title>

		<meta name="description" content="" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="#(CPATH)/assets/css/bootstrap.css" />
		<link rel="stylesheet" href="#(CPATH)/assets/css/font-awesome.css" />

		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="#(CPATH)/assets/css/bootstrap-table.css">
		<link rel="stylesheet" href="#(CPATH)/assets/css/basejace.css">
		<link rel="stylesheet" href="#(CPATH)/assets/js/jstree/themes/default/style.css"><!-- 使用jstree插件 -->
		
		<!-- text fonts -->
		<link rel="stylesheet" href="#(CPATH)/assets/css/ace-fonts.css" />

		<!-- ace styles -->
		<link rel="stylesheet" href="#(CPATH)/assets/css/ace.css" class="ace-main-stylesheet" id="main-ace-style" />

		<!--[if lte IE 9]>
			<link rel="stylesheet" href="#(CPATH)/assets/css/ace-part2.css" class="ace-main-stylesheet" />
		<![endif]-->

		<!--[if lte IE 9]>
		  <link rel="stylesheet" href="#(CPATH)/assets/css/ace-ie.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->
		<script src="#(CPATH)/assets/js/ace-extra.js"></script>

		<!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

		<!--[if lte IE 8]>
		<script src="#(CPATH)/assets/js/html5shiv.js"></script>
		<script src="#(CPATH)/assets/js/respond.js"></script>
		<![endif]-->
	</head>

	<body class="no-skin">
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>
			<div class="main-content">
				<div class="page-content">
					
					<div class="row">
						<div class="col-xs-12 col-sm-3">
						<button class="btn btn-xs btn-info btn-block" onclick="window.location.reload(); return false;"><i class="ace-icon glyphicon glyphicon-refresh"></i>刷新</button>
							<div id="controlTree" style="padding-left:2px;">
							</div>
						</div>
						<div class="col-xs-12 col-sm-9">
							<iframe id="contentFrame" src="#(CPATH)/system/control/view" style="width:100%;height:600px;" class="body-iframe" frameborder="0" scrolling="no" seamless></iframe>
						</div>
					</div>
				</div> <!-- ./page-content -->
			</div> <!-- ./main-content -->
		</div>
		<!-- basic scripts -->
		<!--[if !IE]> -->
		<script type="text/javascript">
			window.jQuery || document.write("<script src='#(CPATH)/assets/js/jquery.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='#(CPATH)/assets/js/jquery1x.js'>"+"<"+"/script>");
</script>
<![endif]-->
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='#(CPATH)/assets/js/jquery.mobile.custom.js'>"+"<"+"/script>");
		</script>
		<script src="#(CPATH)/assets/js/bootstrap.js"></script>

		<!-- page specific plugin scripts -->
		<script src="#(CPATH)/assets/js/bootstrap-table/bootstrap-table.js"></script>
		<script src="#(CPATH)/assets/js/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
		<script src="#(CPATH)/assets/js/bootbox.js"></script>
		<script src="#(CPATH)/assets/js/jstree/jstree.js"></script>
		
		<!-- ace scripts -->
		<script src="#(CPATH)/assets/js/ace/elements.scroller.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.colorpicker.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.fileinput.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.typeahead.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.wysiwyg.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.spinner.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.treeview.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.wizard.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.aside.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.ajax-content.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.touch-drag.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.sidebar.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.sidebar-scroll-1.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.submenu-hover.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.widget-box.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.settings.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.settings-rtl.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.settings-skin.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.widget-on-reload.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.searchbox-autocomplete.js"></script>

		<!-- inline scripts related to this page -->
		<script type="text/javascript">
			var cmdView = "#(CPATH)/system/control/view";
			var cmdDelete = "#(CPATH)/system/user/delete";
			$(function(){
				
				$("#controlTree")
					.on("changed.jstree", function (e, data) {
						if(data.selected.length) {
							//alert('The selected node is: ' + data.instance.get_node(data.selected[0]).text);
							console.log("select the node: " + data.instance.get_node(data.selected[0]).id );
							$("#contentFrame").attr("src", cmdView + "?PK=" + data.instance.get_node(data.selected[0]).id);
						}
					})
					.bind("loaded.jstree", function (e, data) {
						data.instance.open_all();
					})
					.jstree({
						'core' : {
							'multiple' : false,
							'data'     : {
								'url'  : "#(CPATH)/system/control/tree",
								'dataType' : "json"
							}
							/*
							'data' : [
								{
									"text" : "公司菜单", 
									"state" : { "opened" : true },
									"children" : [
										{ "text" : "Child node 1", "id" : 1 },
										{ "text" : "Child node 2", "id" : 2 }
								]}
							]
							*/
						},
						'plugins' : ["wholerow","contextmenu"],
						"contextmenu": {/*    
				            "items": {    
				                "create": null,    
				                "rename": null,    
				                "remove": null,    
				                "ccp": null,    
				                "add": {    
				                    "label": "add",    
				                    "action": function (obj) {  
				                        var inst = jQuery.jstree.reference(obj.reference);    
				                        var clickedNode = inst.get_node(obj.reference);   
				                        alert("add operation--clickedNode's id is:" + clickedNode.id);  
				                    }    
				                },    
				                "delete": {    
				                    "label": "delete",    
				                    "action": function (obj) {  
				                        var inst = jQuery.jstree.reference(obj.reference);    
				                        var clickedNode = inst.get_node(obj.reference);   
				                        alert("delete operation--clickedNode's id is:" + clickedNode.id);  
				                    }    
				                }    
				            } */   
				        }   
						
					});
				
			});
			
			function dictTranslate(value, row, index) {
				//value是当前列的值
				//row 是当前行的数据对象 {colname1: colvalue1, colname2: colvalue2...}，可以使用JSON.stringify(row)来打印出来
				//index 是页面上的表格的当前第几行,从0开始
				if (value=="1") return "男";
				else if (value=="0") return "女";
				else if (value=="2") return "未知";
			}
			
			function del() {
				var selectObj = $("#datatable").bootstrapTable('getAllSelections');
				var pks = "";
				for (var i=0; i< selectObj.length; i++){
					pks += selectObj[i].userid + ","
				}
				
				if (pks == "") {
					bootbox.alert({
						buttons: {  
			               ok: {  
			                    label: '我是ok按钮',  
			                    className: 'btn-myStyle'  
			                }  
			            },  
			            message: '请先选择要删除的记录',  
			            callback: function() {  
			                alert('关闭了alert');  
			            },  
			            title: "bootbox alert也可以添加标题哦", 
					});
					return;
				}
				
				bootbox.confirm("你确定要删除 " + selectObj.length + "条记录吗？", function (result) {  
	                if(result) {  
	                    window.location = cmdDelete + "?PK=" + pks;
	                } else {  
	                    
	                }  
	            });  
				
				//alert(selectObj.length);
				//alert('getSelections: ' + JSON.stringify($("#datatable").bootstrapTable('getAllSelections')));
			}
			
			function add() {
				location.href = "#(CPATH)/system/user/add";
			}
			
			function modify() {
				location.href = "#(CPATH)/system/user/add";
			}
			
			function card() {
				
			}
			
			function query() {
				$("#datatable").bootstrapTable({pageNumber: 1});
				$("#datatable").bootstrapTable("refresh");
			}
			
			
			
			
			
		</script>
	</body>
</html>
